package com.op.parcel.manage.config.security.authentication;

import com.op.parcel.common.api.R;
import com.op.parcel.common.enums.ResultEnum;
import com.op.parcel.manage.config.security.util.HttpDataUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 未认证
 * @author xuan🐽
 */
@Component
@Slf4j
public class DeniedHandler implements AccessDeniedHandler {

	@Override
	public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) {
		HttpDataUtil.respJson(response, R.error(ResultEnum.UNAUTHORIZE.getCode(), "抱歉，您没有访问权限"));
	}

}
